﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

namespace HotelProject
{
    public class DropDownItemGenerator
    {
        public static void populateFloorNumbersInDropDownBox(DropDownList list)
        {
            MySQLDatabaseConnector db = new MySQLDatabaseConnector();
            int[] floors = db.getFloors();
            List<System.Web.UI.WebControls.ListItem> floorsAsItems = new List<System.Web.UI.WebControls.ListItem>();

            floorsAsItems.Add(new ListItem("All Floors", null));
            foreach (int floor in floors)
            {
                floorsAsItems.Add(new ListItem(floor.ToString(), floor.ToString()));
            }

            list.DataSource = floorsAsItems;
            list.DataBind();
        }

        public static void populateRoomNumbersInDropDownBox(DropDownList list)
        {
            MySQLDatabaseConnector db = new MySQLDatabaseConnector();
            int[] roomNumbers = db.getRoomNumbers();
            List<System.Web.UI.WebControls.ListItem> roomNumbersAsItems = new List<System.Web.UI.WebControls.ListItem>();

            roomNumbersAsItems.Add(new ListItem("All Rooms", null));
            foreach (int roomNumber in roomNumbers)
            {
                roomNumbersAsItems.Add(new ListItem(roomNumber.ToString(), roomNumber.ToString()));
            }

            list.DataSource = roomNumbersAsItems;
            list.DataBind();
        }

        public static void populatePricesInDropDownBox(DropDownList list)
        {
            MySQLDatabaseConnector db = new MySQLDatabaseConnector();
            int[] prices = db.getPrices();
            List<System.Web.UI.WebControls.ListItem> pricesAsItems = new List<System.Web.UI.WebControls.ListItem>();

            pricesAsItems.Add(new ListItem("All Prices", null));
            foreach (int price in prices)
            {
                pricesAsItems.Add(new ListItem(price.ToString(), price.ToString()));
            }

            list.DataSource = pricesAsItems;
            list.DataBind();
        }


        public static void populateBedSizesInDropDownBox(DropDownList list)
        {
            MySQLDatabaseConnector db = new MySQLDatabaseConnector();
            String[] bedSizes = db.getBedSizes();
            List<System.Web.UI.WebControls.ListItem> bedSizesAsListItems = new List<System.Web.UI.WebControls.ListItem>();

            bedSizesAsListItems.Add(new ListItem("All Bed Sizes", "0"));
            foreach (String bedSize in bedSizes)
            {
                bedSizesAsListItems.Add(new ListItem(bedSize, bedSize));
            }

            list.DataSource = bedSizesAsListItems;
            list.DataBind();
        }

        public static void populateHotelsInDropDown(DropDownList list)
        {
            MySQLDatabaseConnector db = new MySQLDatabaseConnector();

            hotel[] hotels = db.getHotels();
            List<System.Web.UI.WebControls.ListItem> hotelsAsLitsItems = new List<System.Web.UI.WebControls.ListItem>();

            hotelsAsLitsItems.Add(new ListItem("All Hotels", "0"));
            foreach (hotel _hotel in hotels)
            {
                hotelsAsLitsItems.Add(new ListItem(_hotel.hotelName, _hotel.hotelID.ToString()));
            }

            list.DataSource = hotelsAsLitsItems;
            list.DataBind();
        }



        public static void populateViewsDropDown(DropDownList list)
        {
            MySQLDatabaseConnector db = new MySQLDatabaseConnector();
            String[] views = db.getViews();
            List<System.Web.UI.WebControls.ListItem> viewsInRooms = new List<System.Web.UI.WebControls.ListItem>();

            viewsInRooms.Add(new ListItem("All Views", "0"));
            foreach (String view in views)
            {
                viewsInRooms.Add(new ListItem(view, view));
            }

            list.DataSource = viewsInRooms;
            list.DataBind();

        }
    }
}